//
//  RNTYYLabelManager.m
//  RNCommunity
//
//  Created by 朱吉峥 on 2020/3/5.
//  Copyright © 2020 朱吉峥. All rights reserved.
//

#import "RNTYYLabelManager.h"

@interface RNTYYLabelManager ()

@property (nonatomic, strong) NSMutableDictionary *cachedDict;
@property (nonatomic, strong) NSOperationQueue *queue;

@end

@implementation RNTYYLabelManager

+ (instancetype)manager
{
    static RNTYYLabelManager *cache = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        cache = [RNTYYLabelManager new];
    });
    return cache;
}

- (NSMutableDictionary *)cachedDict
{
    if (!_cachedDict) {
        _cachedDict = [NSMutableDictionary dictionary];
    }
    return _cachedDict;
}

+ (void)cacheObj:(id)obj forKey:(NSDictionary *)dict;
{
    RNTYYLabelManager *manager = [RNTYYLabelManager manager];
    [manager.cachedDict setObject:obj forKey:dict];
}

+ (id)getObjByKey:(NSDictionary *)dict;
{
    RNTYYLabelManager *manager = [RNTYYLabelManager manager];
    return [manager.cachedDict objectForKey:dict];
}

+ (NSArray *)emojiArr
{
    return @[@"paishou.gif", @"wudao.gif"];
}

+ (NSArray *)emojiNameArr
{
    return @[@"[拍手]", @"[舞蹈]"];
}

- (NSOperationQueue *)queue
{
    if (!_queue) {
        _queue = [NSOperationQueue new];
        _queue.maxConcurrentOperationCount = 2;
    }
    return _queue;
}

+ (void)addOperationWithBlock:(void (^)(void))block
{
    RNTYYLabelManager *manager = [RNTYYLabelManager manager];
    [manager.queue addOperationWithBlock:block];
}
@end
